wayland: don't init if XDG_RUNTIME_DIR missing
authorRyan Lortie <desrt@desrt.ca>
Mon, 20 Oct 2014 21:16:22 +0000 (17:16 -0400)
committerRyan Lortie <desrt@desrt.ca>
Tue, 21 Oct 2014 12:12:12 +0000 (08:12 -0400)
wayland doesn't strictly follow the XDG_RUNTIME_DIR spec by falling back
to another directory in case the runtime dir is not properly set.

When this variable is unset, wayland will log an error to us, which we
treat as fatal, aborting the entire program.

Skip ourselves all the trouble and don't try to bring up the wayland
backend when we know it will fail in this way.

https://bugzilla.gnome.org/show_bug.cgi?id=738873

gdk/wayland/gdkdisplay-wayland.c

index 5b6fc9209900a3b4533cc01e5ad65810d35ce3bb..d9fffe44c27df632b949abbc9914c3e2feaf2db0 100644 (file)
@@ -217,6 +217,13 @@ _gdk_wayland_display_open (const gchar *display_name)
   GdkDisplay *display;
   GdkWaylandDisplay *display_wayland;
 
+  /* If this variable is unset then wayland initialisation will surely
+   * fail, logging a fatal error in the process.  Save ourselves from
+   * that.
+   */
+  if (g_getenv ("XDG_RUNTIME_DIR") == NULL)
+    return NULL;
+
   wl_log_set_handler_client(log_handler);
 
   wl_display = wl_display_connect(display_name);